﻿package mortal.game.view.forging.view.compound
{
    import com.mui.controls.*;
    import com.mui.utils.*;
    import mortal.common.global.*;
    import mortal.game.cache.*;
    import mortal.game.resource.*;
    import mortal.game.resource.info.item.*;
    import mortal.game.view.common.*;
    import mortal.game.view.common.item.*;

    public class CompoundRecipe extends GSprite
    {
        private var _item:BaseItem;
        private var _num:GTextFiled;
        private var _baseNeedNum:int;
        private var _multiple:int;
        private var _onlyUseUnbind:Boolean;

        public function CompoundRecipe()
        {
            return;
        }// end function

        override protected function createDisposedChildrenImpl() : void
        {
            super.createDisposedChildrenImpl();
            this.pushUIToDisposeVec(UIFactory.gImageBitmap(ImagesConst.SynthesisPanelItemBg, 0, 0, this));
            this._item = UICompomentPool.getUICompoment(BaseItem);
            this._item.x = 17;
            this._item.y = 17;
            this._item.setItemStyle(ItemStyleConst.Small, null);
            this.addChild(this._item);
            this._num = UIFactory.gTextField("", 10, 65, 60, 20, this, GlobalStyle.textFormatBai.center());
            return;
        }// end function

        override protected function disposeImpl(param1:Boolean = true) : void
        {
            this._item.dispose(param1);
            this._item = null;
            this._num.dispose(param1);
            this._num = null;
            this._baseNeedNum = 0;
            super.disposeImpl(param1);
            return;
        }// end function

        public function updatePackItem(param1:Object = null) : void
        {
            if (this.isDisposed)
            {
                return;
            }
            var _loc_2:* = this._item.itemData;
            var _loc_3:* = Cache.instance.pack.backPackCache.getItemCountByItemCode(_loc_2.itemInfo.codeUnbind, !this._onlyUseUnbind);
            var _loc_4:String = "";
            if (_loc_3 >= this._baseNeedNum * this._multiple)
            {
                _loc_4 = "<font color=\'#1ccc31\'>" + _loc_3;
            }
            else
            {
                _loc_4 = "<font color=\'#df2121\'>" + _loc_3;
            }
            this._num.htmlText = _loc_4 + "/" + this._baseNeedNum * this._multiple + "个</font>";
            return;
        }// end function

        public function resetUseBinItem(param1:int, param2:Boolean) : void
        {
            this._multiple = param1;
            this._onlyUseUnbind = param2;
            this._item.isBind = !this._onlyUseUnbind;
            this.updatePackItem();
            return;
        }// end function

        public function updateItem(param1:ItemData, param2:int, param3:int, param4:Boolean) : void
        {
            this._item.itemData = param1;
            this._baseNeedNum = param2;
            this.resetUseBinItem(param3, param4);
            return;
        }// end function

    }
}
